/**
 * output package name
 */
package com.kingdee.eas.minghua.material.voucher.client;

import java.awt.event.ActionEvent;
import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.extendcontrols.BizDataFormat;
import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTDefaultCellEditor;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.ctrl.kdf.util.render.ObjectValueRender;
import com.kingdee.bos.ctrl.swing.event.DataChangeEvent;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.basedata.master.account.AccountViewInfo;
import com.kingdee.eas.basedata.master.auxacct.AsstActTypeFactory;
import com.kingdee.eas.basedata.master.auxacct.AsstActTypeInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.fdc.basedata.FDCSQLBuilder;
import com.kingdee.jdbc.rowset.IRowSet;

/**
 * output class name
 */
public class ParamEditUI extends AbstractParamEditUI
{
    private static final Logger logger = CoreUIObject.getLogger(ParamEditUI.class);
    
    /**
     * output class constructor
     */
    public ParamEditUI() throws Exception
    {
        super();
    }
    /**
     * output loadFields method
     */
    public void loadFields()
    {
        super.loadFields();
    }

    /**
     * output storeFields method
     */
    public void storeFields()
    {
        super.storeFields();
    }
    public void onLoad() throws Exception {
		super.onLoad();
		EntityViewInfo evi = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();
		filter.getFilterItems().add(new FilterItemInfo("cu.id", SysContext.getSysContext().getCurrentCtrlUnit().getId().toString(), CompareType.EQUALS));
		evi.setFilter(filter);
		prmtaccount.setEntityViewInfo(evi);
		prmtfAccount.setEntityViewInfo(evi);
//		initAsstActTypeQuery();
	}
    
	protected void prmtaccount_dataChanged(DataChangeEvent e) throws Exception {
		super.prmtaccount_dataChanged(e);
		getAsstActTypeByAccount(kdtE1,(AccountViewInfo)prmtaccount.getValue());
	}
	protected void prmtfAccount_dataChanged(DataChangeEvent e) throws Exception {
		super.prmtfAccount_dataChanged(e);
        getAsstActTypeByAccount(kdtE2,(AccountViewInfo)prmtfAccount.getValue());
	}
	
	public void getAsstActTypeByAccount(KDTable tblMain,AccountViewInfo info) throws BOSException, EASBizException, SQLException{
		if(info!=null&&info.getCAA()!=null){
			tblMain.removeRows();
// 			if(tblMain.equals(kdtE1)){
//				int size = editData.getE1().size();
//		        for(int i = 0; i < size; i++)
//		        {
//		        	editData.getE1().removeObject(0);
//		        }
//			}
//			if(tblMain.equals(kdtE2)){
//				int size = editData.getE2().size();
//		        for(int i = 0; i < size; i++)
//		        {
//		        	editData.getE2().removeObject(0);
//		        }
//			}
			String assAccountId=info.getCAA().getId().toString();
			String asstActTypeId=null;
			AsstActTypeInfo aatInfo=null;
			FDCSQLBuilder builder = new FDCSQLBuilder();
			String sql="select FAsstActTypeID from T_BD_AsstActGroupDetail where FAsstAccountID='"+assAccountId+"'";
			builder.appendSql(sql);
			IRowSet rowset=(IRowSet)builder.executeQuery();
			while(rowset.next()){
				asstActTypeId=rowset.getString("FAsstActTypeID");
				aatInfo=AsstActTypeFactory.getRemoteInstance().getAsstActTypeInfo(new ObjectUuidPK(asstActTypeId));
				IRow row = tblMain.addRow();
				row.getCell(1).setValue(aatInfo);
			}
		}
	}
	public void initAsstActTypeQuery(){
		//E1
		final KDBizPromptBox kdtE1_debitAsstActType_PromptBox = new KDBizPromptBox();
        kdtE1_debitAsstActType_PromptBox.setQueryInfo("com.kingdee.eas.basedata.master.auxacct.app.F7AsstActTypeQuery");
        kdtE1_debitAsstActType_PromptBox.setVisible(true);
        kdtE1_debitAsstActType_PromptBox.setEditable(true);
        kdtE1_debitAsstActType_PromptBox.setDisplayFormat("$number$");
        kdtE1_debitAsstActType_PromptBox.setEditFormat("$number$");
        kdtE1_debitAsstActType_PromptBox.setCommitFormat("$number$");
        KDTDefaultCellEditor kdtE1_debitAsstActType_CellEditor = new KDTDefaultCellEditor(kdtE1_debitAsstActType_PromptBox);
        this.kdtE1.getColumn("debitAsstActType").setEditor(kdtE1_debitAsstActType_CellEditor);
        ObjectValueRender kdtE1_debitAsstActType_OVR = new ObjectValueRender();
        kdtE1_debitAsstActType_OVR.setFormat(new BizDataFormat("$name$"));
        this.kdtE1.getColumn("debitAsstActType").setRenderer(kdtE1_debitAsstActType_OVR);
        //E2
        final KDBizPromptBox kdtE2_creditAsstActType_PromptBox = new KDBizPromptBox();
        kdtE2_creditAsstActType_PromptBox.setQueryInfo("com.kingdee.eas.basedata.master.auxacct.app.F7AsstActTypeQuery");
        kdtE2_creditAsstActType_PromptBox.setVisible(true);
        kdtE2_creditAsstActType_PromptBox.setEditable(true);
        kdtE2_creditAsstActType_PromptBox.setDisplayFormat("$number$");
        kdtE2_creditAsstActType_PromptBox.setEditFormat("$number$");
        kdtE2_creditAsstActType_PromptBox.setCommitFormat("$number$");
        KDTDefaultCellEditor kdtE2_creditAsstActType_CellEditor = new KDTDefaultCellEditor(kdtE2_creditAsstActType_PromptBox);
        this.kdtE2.getColumn("creditAsstActType").setEditor(kdtE2_creditAsstActType_CellEditor);
        ObjectValueRender kdtE2_creditAsstActType_OVR = new ObjectValueRender();
        kdtE2_creditAsstActType_OVR.setFormat(new BizDataFormat("$name$"));
        this.kdtE2.getColumn("creditAsstActType").setRenderer(kdtE2_creditAsstActType_OVR);
	}
    /**
     * output actionPageSetup_actionPerformed
     */
    public void actionPageSetup_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPageSetup_actionPerformed(e);
    }

    /**
     * output actionExitCurrent_actionPerformed
     */
    public void actionExitCurrent_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExitCurrent_actionPerformed(e);
    }

    /**
     * output actionHelp_actionPerformed
     */
    public void actionHelp_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionHelp_actionPerformed(e);
    }

    /**
     * output actionAbout_actionPerformed
     */
    public void actionAbout_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAbout_actionPerformed(e);
    }

    /**
     * output actionOnLoad_actionPerformed
     */
    public void actionOnLoad_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionOnLoad_actionPerformed(e);
    }

    /**
     * output actionSendMessage_actionPerformed
     */
    public void actionSendMessage_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionSendMessage_actionPerformed(e);
    }

    /**
     * output actionCalculator_actionPerformed
     */
    public void actionCalculator_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCalculator_actionPerformed(e);
    }

    /**
     * output actionExport_actionPerformed
     */
    public void actionExport_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExport_actionPerformed(e);
    }

    /**
     * output actionExportSelected_actionPerformed
     */
    public void actionExportSelected_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSelected_actionPerformed(e);
    }

    /**
     * output actionRegProduct_actionPerformed
     */
    public void actionRegProduct_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionRegProduct_actionPerformed(e);
    }

    /**
     * output actionPersonalSite_actionPerformed
     */
    public void actionPersonalSite_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPersonalSite_actionPerformed(e);
    }

    /**
     * output actionProcductVal_actionPerformed
     */
    public void actionProcductVal_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionProcductVal_actionPerformed(e);
    }

    /**
     * output actionExportSave_actionPerformed
     */
    public void actionExportSave_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSave_actionPerformed(e);
    }

    /**
     * output actionExportSelectedSave_actionPerformed
     */
    public void actionExportSelectedSave_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSelectedSave_actionPerformed(e);
    }

    /**
     * output actionSave_actionPerformed
     */
    public void actionSave_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionSave_actionPerformed(e);
    }

    /**
     * output actionSubmit_actionPerformed
     */
    public void actionSubmit_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionSubmit_actionPerformed(e);
    }

    /**
     * output actionCancel_actionPerformed
     */
    public void actionCancel_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCancel_actionPerformed(e);
    }

    /**
     * output actionCancelCancel_actionPerformed
     */
    public void actionCancelCancel_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCancelCancel_actionPerformed(e);
    }

    /**
     * output actionFirst_actionPerformed
     */
    public void actionFirst_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionFirst_actionPerformed(e);
    }

    /**
     * output actionPre_actionPerformed
     */
    public void actionPre_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPre_actionPerformed(e);
    }

    /**
     * output actionNext_actionPerformed
     */
    public void actionNext_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionNext_actionPerformed(e);
    }

    /**
     * output actionLast_actionPerformed
     */
    public void actionLast_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionLast_actionPerformed(e);
    }

    /**
     * output actionPrint_actionPerformed
     */
    public void actionPrint_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPrint_actionPerformed(e);
    }

    /**
     * output actionPrintPreview_actionPerformed
     */
    public void actionPrintPreview_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPrintPreview_actionPerformed(e);
    }

    /**
     * output actionCopy_actionPerformed
     */
    public void actionCopy_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCopy_actionPerformed(e);
    }

    /**
     * output actionAddNew_actionPerformed
     */
    public void actionAddNew_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAddNew_actionPerformed(e);
    }

    /**
     * output actionEdit_actionPerformed
     */
    public void actionEdit_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionEdit_actionPerformed(e);
    }

    /**
     * output actionRemove_actionPerformed
     */
    public void actionRemove_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionRemove_actionPerformed(e);
    }

    /**
     * output actionAttachment_actionPerformed
     */
    public void actionAttachment_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAttachment_actionPerformed(e);
    }

    /**
     * output actionSubmitOption_actionPerformed
     */
    public void actionSubmitOption_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionSubmitOption_actionPerformed(e);
    }

    /**
     * output actionReset_actionPerformed
     */
    public void actionReset_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionReset_actionPerformed(e);
    }

    /**
     * output actionMsgFormat_actionPerformed
     */
    public void actionMsgFormat_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionMsgFormat_actionPerformed(e);
    }

    /**
     * output getBizInterface method
     */
    protected com.kingdee.eas.framework.ICoreBase getBizInterface() throws Exception
    {
        return com.kingdee.eas.minghua.material.voucher.ParamFactory.getRemoteInstance();
    }

    /**
     * output createNewData method
     */
    protected com.kingdee.bos.dao.IObjectValue createNewData()
    {
        com.kingdee.eas.minghua.material.voucher.ParamInfo objectValue = new com.kingdee.eas.minghua.material.voucher.ParamInfo();
        objectValue.setCreator((com.kingdee.eas.base.permission.UserInfo)(com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentUser()));
		
        return objectValue;
    }
	

}